<template>
  <van-popup
    v-model:show="roomState.ruleOpen"
    lock-scroll
    z-index="3000"
    position="bottom"
    class="game-rule-popup"
  >
    <div
      class="flex h-[40px] items-center justify-between border-[#eee] border-solid border-b-[1px]"
    >
      <div
        class="rule-left w-[50px] h-[40px] flex items-center justify-center"
        @click="roomState.ruleOpen = false"
      >
        <van-icon name="arrow-down" />
      </div>
      <div class="h-[40px] flex-1 w-0 text-[16px] flex items-center justify-center">玩法说明</div>
      <div class="w-[50px] h-[40px]"></div>
    </div>
    <div class="flex-1 overflow-auto">
      <component :is="getRule(lotteryTypeId)"></component>
    </div>
  </van-popup>
</template>
<script lang="ts" setup>
import { getRule } from "@/utils/game";

const roomState = inject<RoomState>("roomState") as RoomState;

const lotteryTypeId = computed(() => {
  return roomState.gameCategory || 3;
});
</script>
<style lang="scss">
.game-rule-popup {
  background-color: #fff;
  max-width: 375px;
  width: 100%;
  height: calc(100% - 122px);
  left: calc((100vw - 375px) / 2) !important;
  border-radius: 15px 15px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
</style>
<style lang="scss" scoped>
.rule-left {
  .van-icon {
    font-size: 16px;
    color: #ccc;
  }
}
</style>
